@@ -54,7 +54,7 @@ class LensmanIncomeExpensesInfoAdmin(admin.ModelAdmin):  | 
            ||
| 54 | 54 | 
                 | 
            
| 55 | 55 | 
                class UserInfoAdmin(admin.ModelAdmin):  | 
            
| 56 | 56 | 
                     readonly_fields = ('user_id', )
               | 
            
| 57 | 
                -    list_display = ('user_id', 'user_from', 'username', 'wx_uid', 'unionid', 'name', 'sex', 'nickname', 'phone', 'location', 'balance', 'user_status', 'status', 'created_at', 'updated_at')
               | 
            |
| 57 | 
                +    list_display = ('user_id', 'user_from', 'username', 'openid', 'unionid', 'name', 'sex', 'nickname', 'phone', 'location', 'balance', 'user_status', 'status', 'created_at', 'updated_at')
               | 
            |
| 58 | 58 | 
                     search_fields = ('name', 'phone', 'location')
               | 
            
| 59 | 59 | 
                     list_filter = ('user_from', 'sex', 'user_status', 'status')
               | 
            
| 60 | 60 | 
                 | 
            
                @@ -0,0 +1,23 @@  | 
            ||
| 1 | 
                +# -*- coding: utf-8 -*-  | 
            |
| 2 | 
                +from __future__ import unicode_literals  | 
            |
| 3 | 
                +  | 
            |
| 4 | 
                +from django.db import models, migrations  | 
            |
| 5 | 
                +  | 
            |
| 6 | 
                +  | 
            |
| 7 | 
                +class Migration(migrations.Migration):  | 
            |
| 8 | 
                +  | 
            |
| 9 | 
                + dependencies = [  | 
            |
| 10 | 
                +        ('account', '0015_auto_20160713_1646'),
               | 
            |
| 11 | 
                + ]  | 
            |
| 12 | 
                +  | 
            |
| 13 | 
                + operations = [  | 
            |
| 14 | 
                + migrations.RemoveField(  | 
            |
| 15 | 
                + model_name='userinfo',  | 
            |
| 16 | 
                + name='wx_uid',  | 
            |
| 17 | 
                + ),  | 
            |
| 18 | 
                + migrations.AddField(  | 
            |
| 19 | 
                + model_name='userinfo',  | 
            |
| 20 | 
                + name='openid',  | 
            |
| 21 | 
                + field=models.CharField(null=True, max_length=255, blank=True, help_text='\u5fae\u4fe1 Open ID', unique=True, verbose_name='openid', db_index=True),  | 
            |
| 22 | 
                + ),  | 
            |
| 23 | 
                + ]  | 
            
                @@ -194,7 +194,7 @@ class UserInfo(CreateUpdateMixin):  | 
            ||
| 194 | 194 | 
                username = models.CharField(_(u'username'), max_length=255, blank=True, null=True, help_text=u'用户用户名', db_index=True, unique=True)  | 
            
| 195 | 195 | 
                password = models.CharField(_(u'password'), max_length=255, blank=True, null=True, help_text=u'用户密码')  | 
            
| 196 | 196 | 
                # 微信授权用户  | 
            
| 197 | 
                - wx_uid = models.CharField(_(u'wx_uid'), max_length=255, blank=True, null=True, help_text=u'微信唯一标识', db_index=True, unique=True)  | 
            |
| 197 | 
                + openid = models.CharField(_(u'openid'), max_length=255, blank=True, null=True, help_text=u'微信 Open ID', db_index=True, unique=True)  | 
            |
| 198 | 198 | 
                unionid = models.CharField(_(u'unionid'), max_length=255, blank=True, null=True, help_text=u'微信 Union ID', db_index=True, unique=True)  | 
            
| 199 | 199 | 
                # 用户基本信息  | 
            
| 200 | 200 | 
                name = models.CharField(_(u'name'), max_length=255, blank=True, null=True, help_text=u'用户姓名')  | 
            
                @@ -119,8 +119,8 @@ def user_login_api(request):  | 
            ||
| 119 | 119 | 
                def user_wx_authorize_api(request):  | 
            
| 120 | 120 | 
                     user_id = request.POST.get('user_id', '')
               | 
            
| 121 | 121 | 
                 | 
            
| 122 | 
                -    openid = wx_uid = request.POST.get('wx_uid', '')
               | 
            |
| 123 | 122 | 
                     unionid = request.POST.get('unionid', '')
               | 
            
| 123 | 
                +    openid = request.POST.get('wx_uid', '')
               | 
            |
| 124 | 124 | 
                 | 
            
| 125 | 125 | 
                     sex = request.POST.get('sex', 0)
               | 
            
| 126 | 126 | 
                     nickname = request.POST.get('nickname', '') or request.POST.get('screen_name', '')
               | 
            
                @@ -136,7 +136,7 @@ def user_wx_authorize_api(request):  | 
            ||
| 136 | 136 | 
                user = None  | 
            
| 137 | 137 | 
                 | 
            
| 138 | 138 | 
                if user:  | 
            
| 139 | 
                - user.unionid = unionid  | 
            |
| 139 | 
                + user.openid = openid  | 
            |
| 140 | 140 | 
                user.sex = sex  | 
            
| 141 | 141 | 
                user.nickname = nickname  | 
            
| 142 | 142 | 
                user.avatar = avatar  | 
            
                @@ -159,7 +159,7 @@ def user_wx_authorize_api(request):  | 
            ||
| 159 | 159 | 
                 | 
            
| 160 | 160 | 
                if user and user.user_status == UserInfo.ASSIGN:  | 
            
| 161 | 161 | 
                user.user_from = UserInfo.WX_USER  | 
            
| 162 | 
                - user.wx_uid = wx_uid  | 
            |
| 162 | 
                + user.openid = openid  | 
            |
| 163 | 163 | 
                user.unionid = unionid  | 
            
| 164 | 164 | 
                user.sex = sex  | 
            
| 165 | 165 | 
                user.nickname = nickname  | 
            
                @@ -174,7 +174,7 @@ def user_wx_authorize_api(request):  | 
            ||
| 174 | 174 | 
                user = UserInfo.objects.create(  | 
            
| 175 | 175 | 
                user_id=CurtailUUID.uuid(UserInfo, 'user_id'),  | 
            
| 176 | 176 | 
                user_from=UserInfo.WX_USER,  | 
            
| 177 | 
                - wx_uid=wx_uid,  | 
            |
| 177 | 
                + openid=openid,  | 
            |
| 178 | 178 | 
                unionid=unionid,  | 
            
| 179 | 179 | 
                sex=sex,  | 
            
| 180 | 180 | 
                nickname=nickname,  | 
            
                @@ -34,6 +34,7 @@ def lensman_submit_api(request):  | 
            ||
| 34 | 34 | 
                :return:  | 
            
| 35 | 35 | 
                """  | 
            
| 36 | 36 | 
                     unionid = request.POST.get('unionid', '')
               | 
            
| 37 | 
                +    openid = request.POST.get('openid', '')
               | 
            |
| 37 | 38 | 
                     phone = request.POST.get('phone', '')
               | 
            
| 38 | 39 | 
                 | 
            
| 39 | 40 | 
                if LensmanInfo.objects.filter(phone=phone).exclude(unionid=unionid).exists():  | 
            
                @@ -88,6 +89,14 @@ def lensman_login_api(request):  | 
            ||
| 88 | 89 | 
                @logit  | 
            
| 89 | 90 | 
                def lensman_wx_authorize_api(request):  | 
            
| 90 | 91 | 
                     unionid = request.POST.get('unionid', '')
               | 
            
| 92 | 
                +    openid = request.POST.get('openid', '')
               | 
            |
| 93 | 
                +  | 
            |
| 94 | 
                +    sex = request.POST.get('sex', 0)
               | 
            |
| 95 | 
                +    nickname = request.POST.get('nickname', '') or request.POST.get('screen_name', '')
               | 
            |
| 96 | 
                +    avatar = request.POST.get('headimgurl', '') or request.POST.get('profile_image_url', '')
               | 
            |
| 97 | 
                +    country = request.POST.get('country', '')
               | 
            |
| 98 | 
                +    province = request.POST.get('province', '')
               | 
            |
| 99 | 
                +    city = request.POST.get('city', '')
               | 
            |
| 91 | 100 | 
                 | 
            
| 92 | 101 | 
                # 判断 unionid 是否已经存在,如果已经存在,则直接返回改帐户信息  | 
            
| 93 | 102 | 
                try:  | 
            
                @@ -98,6 +107,15 @@ def lensman_wx_authorize_api(request):  | 
            ||
| 98 | 107 | 
                if user.user_status != UserInfo.ACTIVATED:  | 
            
| 99 | 108 | 
                return response(LensmanStatusCode.LENSMAN_NOT_ACTIVATED)  | 
            
| 100 | 109 | 
                 | 
            
| 110 | 
                + user.openid = openid  | 
            |
| 111 | 
                + user.sex = sex  | 
            |
| 112 | 
                + user.nickname = nickname  | 
            |
| 113 | 
                + user.avatar = avatar  | 
            |
| 114 | 
                + user.country = country  | 
            |
| 115 | 
                + user.province = province  | 
            |
| 116 | 
                + user.city = city  | 
            |
| 117 | 
                + user.save()  | 
            |
| 118 | 
                +  | 
            |
| 101 | 119 | 
                return response(200, 'Lensman Login Success', u'摄影师登录成功', user.data)  | 
            
| 102 | 120 | 
                 | 
            
| 103 | 121 | 
                 | 
            
                @@ -148,6 +148,7 @@  | 
            ||
| 148 | 148 | 
                 | 
            
| 149 | 149 | 
                                     return {
               | 
            
| 150 | 150 | 
                unionid: unionid,  | 
            
| 151 | 
                +                        openid: getURLParameter('openid'),
               | 
            |
| 151 | 152 | 
                name: name,  | 
            
| 152 | 153 | 
                                         sex: $('#sex option:checked').val(),
               | 
            
| 153 | 154 | 
                                         phone: $('#phone').val(),
               | 
            
                @@ -318,7 +318,7 @@ def wx_balance_withdraw_api(request):  | 
            ||
| 318 | 318 | 
                     withdraw_type = request.POST.get('withdraw_type', 'TRANSFER')
               | 
            
| 319 | 319 | 
                     amount = int(request.POST.get('amount', 0))
               | 
            
| 320 | 320 | 
                 | 
            
| 321 | 
                - if not user.wx_uid:  | 
            |
| 321 | 
                + if not user.openid:  | 
            |
| 322 | 322 | 
                return response(WithdrawStatusCode.OPENID_NOT_FOUND)  | 
            
| 323 | 323 | 
                 | 
            
| 324 | 324 | 
                if user.balance < amount:  | 
            
                @@ -330,10 +330,10 @@ def wx_balance_withdraw_api(request):  | 
            ||
| 330 | 330 | 
                     wxpay = WeChatPay(wechat.get('appID'), wechat.get('apiKey'), wechat.get('mchID'), mch_cert=wechat.get('mch_cert'), mch_key=wechat.get('mch_key'))
               | 
            
| 331 | 331 | 
                 | 
            
| 332 | 332 | 
                if withdraw_type == 'TRANSFER':  | 
            
| 333 | 
                - ret_data = wxpay.transfer.transfer(user.wx_uid, amount, u'摄影师余额提现,企业付款', check_name='NO_CHECK')  | 
            |
| 333 | 
                + ret_data = wxpay.transfer.transfer(user.openid, amount, u'摄影师余额提现,企业付款', check_name='NO_CHECK')  | 
            |
| 334 | 334 | 
                elif withdraw_type == 'PACKET':  | 
            
| 335 | 335 | 
                ret_data = wxpay.redpack.send(  | 
            
| 336 | 
                - user.wx_uid,  | 
            |
| 336 | 
                + user.openid,  | 
            |
| 337 | 337 | 
                amount,  | 
            
| 338 | 338 | 
                             send_name=wechat.get('redpacket', {}).get('SEND_NAME'),
               | 
            
| 339 | 339 | 
                             nick_name=wechat.get('redpacket', {}).get('NICK_NAME'),
               |